package com.lyxs916.widget.factory;

import android.app.Dialog;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.lyxs916.widget.loading.R;
import com.lyxs916.widget.loading.factory.DialogFactory;

/**
 * 说明:自定义样式dialog的例子
 * 作者： 杨阳; 创建于：  2017-06-09  16:47
 */
public class CustomDialogFactory implements DialogFactory {
    @Override
    public Dialog onCreateDialog(Context context) {
        Dialog dialog = new Dialog(context, R.style.Dialog);
        dialog.setContentView(R.layout.layout_custom_dialog);
        return dialog;
    }

    @Override
    public void setMessage(Dialog dialog, CharSequence message) {
        TextView tv = (TextView) dialog.findViewById(R.id.tv_message);
        if (tv != null) {
            if (TextUtils.isEmpty(message)) {
//                tv.setVisibility(View.GONE);
            } else {
                tv.setVisibility(View.VISIBLE);
                tv.setText(message);
            }
        }
    }

    @Override
    public int getAnimateStyleId() {
        return R.style.Dialog_Alpha_Animation;
    }


}
